# -*- coding: utf-8 -*-
from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
import django.utils.timezone as timezone

# Create your models here.

# User Table
#
GENDER_CHOICES = ((True, '男性'), (False, '女性'))
class TuringUser(models.Model):
    Users = models.OneToOneField(User)                              				#用户登陆名、密码
    UserID = models.CharField(primary_key = True, max_length = 20, verbose_name = u'用户ID')  
    UserGender = models.NullBooleanField(choices = GENDER_CHOICES, verbose_name = u'性别') #选填，可留空
    RoleTypeID = models.CharField(max_length = 10, verbose_name = u'用户类型ID')    #用户类型："admin"为管理员, "student"为学生, "volunteer"为游客
    NickName = models.CharField(max_length = 20, verbose_name = u'昵称')            #用户真正名字
    UserEmail = models.EmailField(verbose_name = u'Email')
    UserPoints = models.IntegerField(default = 0, verbose_name = '用户积分')
    RegisterTime = models.DateTimeField(default = timezone.now, auto_now_add = True, verbose_name = u'注册时间')          		#账户创建时间
    LastLoginTime = models.DateTimeField(verbose_name = u'上次登录时间')           #账户最后一次登录时间
    CurrentTime = models.DateTimeField(verbose_name = u'本次登录时间')
    LastLoginIP = models.IPAddressField(default = '127.0.0.1', verbose_name = u'上次登录IP')
    TotalLoginCount = models.IntegerField(default = 0, verbose_name = u'总计登录次数')
    TotalPostCount = models.IntegerField(default = 0, verbose_name = u'总计发布次数')
    EnshrineString = models.CharField(max_length = 2000, verbose_name = u'关注的标签ID串', null = True)
    QuestionString = models.CharField(max_length = 5000, verbose_name = u'关注的问题ID串', null = True)
    UserQQ = models.CharField(max_length = 15, verbose_name = u'QQ',null=True)
    MobilePhone = models.CharField(max_length = 11, verbose_name = u'手机号码', null = True)      	#电话号码
    #Enabled = models.NullBooleanField(default = False, choices = BOOL_CHOICES, verbose_name = u'邮箱验证')
    Note = models.CharField(default = 'None', max_length = 100, verbose_name = u'备注',null = True)

    def __unicode__(self):
        return self.Users.username + ' ' + self.RoleTypeID


# User role type
#
BOOL_CHOICES = ((True, 'Yes'), (False, 'No'))
class TuringRoleType(models.Model):
	RoleTypeID = models.CharField(primary_key = True, max_length = 10, verbose_name = u'用户类型ID')
	RoleTypeName = models.CharField(max_length = 10, verbose_name = u'用户类型名')
	DeletePermission = models.NullBooleanField(default = False, choices = BOOL_CHOICES, verbose_name = u'删除权限')
	PostPermission = models.NullBooleanField(default = False, choices = BOOL_CHOICES, verbose_name = u'发表权限')
	SuperPermission = models.NullBooleanField(default = False, choices = BOOL_CHOICES, verbose_name = u'超级管理员权限')
	Note = models.CharField(default = 'None', max_length = 100)

	def __unicode__(self):
		return self.RoleTypeID + ' ' + self.RoleTypeName
